package aiaudio.collaborative;

import aiaudio.storage.api.IUser;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Nastya
 */
public class CollaborativeGroupping implements Serializable {

    private List<CollaborativeUserGroup> groups =
            new ArrayList<CollaborativeUserGroup>();

    public void add(IUser user, int groupId, double fit) {
        groups.add(new CollaborativeUserGroup(user, groupId, fit));
    }

    public List<CollaborativeUserGroup> getMembersByUser(IUser user) {
        List<CollaborativeUserGroup> usersGroups =
                new ArrayList<CollaborativeUserGroup>();
        for (CollaborativeUserGroup userGroup : groups) {
            if (userGroup.getUser().equals(user)) {
                usersGroups.add(userGroup);
            }
        }
        return usersGroups;
    }

    public List<CollaborativeUserGroup> getMembersByGroupId(int groupId) {
        List<CollaborativeUserGroup> usersGroups =
                new ArrayList<CollaborativeUserGroup>();
        for (CollaborativeUserGroup userGroup : groups) {
            if (userGroup.getGroupId() == groupId) {
                usersGroups.add(userGroup);
            }
        }
        return usersGroups;
    }
}